package edu.langnan.xiaoli.service.impl;

import edu.langnan.xiaoli.core.dto.NucleicBaseInfoDTO;
import edu.langnan.xiaoli.core.dto.NucleicInfoDTO;
import edu.langnan.xiaoli.core.dto.NucleicParamDTO;
import edu.langnan.xiaoli.core.dto.NucleicStudentInfoDTO;
import edu.langnan.xiaoli.mapper.NucleicAcidMapper;
import edu.langnan.xiaoli.service.NucleicAcidService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author cql
 */
@Service
public class NucleicAcidServiceImpl implements NucleicAcidService {

    @Autowired
    private NucleicAcidMapper nucleicAcidMapper;

    @Override
    public List<NucleicBaseInfoDTO> nucleicAcidList() {
        return nucleicAcidMapper.nucleicAcidList();
    }

    @Override
    public NucleicInfoDTO findNucleicById(Integer nid) {
        NucleicBaseInfoDTO baseInfo = nucleicAcidMapper.findNucleicById(nid);

        NucleicInfoDTO result = new NucleicInfoDTO();

        BeanUtils.copyProperties(baseInfo, result);


        return result;
    }

    @Override
    public List<NucleicStudentInfoDTO> studentOfNucleicList(Integer stuId) {
        return nucleicAcidMapper.studentOfNucleicList(stuId);
    }

    @Override
    public NucleicStudentInfoDTO nucleicById(Integer stuId, Integer nid) {
        return nucleicAcidMapper.nucleicById(stuId, nid);
    }

    @Override
    public void uploadNucleic(NucleicParamDTO param) {
        nucleicAcidMapper.insertNucleicEvidence(param);
    }


}
